<template>
  <div class="main">
    <van-cell-group inset>
      <van-cell>
        <template #title>
          <div class="left">
            <van-image width="48px" height="48px" fit="cover" round :src="obj.avatar" />
            <div class="user">{{ obj.nick_name }}</div>
          </div>
        </template>
        <template #right-icon>
          <div class="right">
            <div>{{ obj.accumulation }}</div>
            <div>累计奖励</div>
          </div>
        </template>
      </van-cell>
    </van-cell-group>
    <div class="box">
      <van-cell-group inset>
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="getShareNumList">
          <van-cell v-for="(item, index) in ShareNumList" :key="index" value-class="value" :value="`+${item.value_show}`">
            <template #title>
              <div class="title_top"> {{ item.note }}</div>
              <div class="title_top1">{{ getArr(item.add_time) }}</div>
            </template>
          </van-cell>
          <van-empty v-if="ShareNumList.length == 0" />
        </van-list>

        <!-- <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="getShareNumList">
          <van-cell v-for="(item, index) in ShareNumList" :key="index" value-class="title" title-class="title"
            :title="item.nick_name" :value="type == 1 ? getArr(item.add_time) : item.AllNum" />
          <van-empty v-if="ShareNumList.length == 0" />
        </van-list> -->

      </van-cell-group>

    </div>

  </div>
</template>

<script>


export default {
  data() {
    return {
      page: 1,
      limit: 10,
      err: false,
      loading: false,
      finished: false,
      type: '',
      obj: this.$store.state.userInfo,
      ShareNumList: []
    }
  },
  created() {
  },
  methods: {
    getArr(add_time) {
      return this.$moment(Number(add_time) * 1000).format('YYYY/MM/DD HH:mm:ss')
    },
    getShareNumList() {
      this.loading = true
      this.$axios.get(this.$api.GetUserGrowthLog, {
        params: {
          page: parseInt(this.ShareNumList.length / this.limit) + 1,  //页码
          limit: this.limit, //每页条数
        },
      }).then((res) => {
        this.loading = false
        if (res.data.code == 1) {
          let result = res.data.data.data
          this.ShareNumList.push(...result)
          if (result.length < this.limit) {
            this.finished = true //大于所有条数则结束加载
          }

          // if (result.length > this.limit) this.page++
        } else {
          // 加载失败时
          this.err = true
        }
      })
    },
  }
}
</script>

<style lang="less" scoped>
.main {
  padding-top: 12px;
  margin-bottom: 40px;

  .left {
    display: flex;
    align-items: center;
    font-size: 14px;

    .user {
      margin-left: 12px;
    }
  }

  .right {
    text-align: center;
    font-size: 14px;
    color: #201D1DFF;

    div:nth-child(1) {
      color: #C60500FF;
      font-size: 16px;
    }
  }

  .box {
    margin-top: 12px;

    .value {
      font-size: 14px;
      font-weight: bold;
      color: red;
    }

    .title_top {
      color: #000000FF;
      font-size: 16px;
    }

    .title_top1 {
      color: #363535FF;
      font-size: 10px;
    }
  }
}
</style>